package control;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ColorPicker;
import javafx.stage.Stage;
import javafx.scene.layout.*;

// 颜色选择器(可以测试颜色)
public class ColorPickerDemo extends Application {
	private Pane root = new Pane();
	private ColorPicker cp;
	
	public static void main(String[] args) {
		Application.launch(args);
	}
	
	@Override
	public void start(Stage stage) {
		
		cp = new ColorPicker();   
		root.getChildren().add(cp);
		
		Scene scene = new Scene(root, 400, 300);
		stage.setScene(scene);
		stage.setTitle("颜色选择器");
		stage.show();
		
		// 颜色属性监听（使面板变成选择的颜色）
		cp.valueProperty().addListener(e -> {
			root.setStyle("-fx-background-color: #" + cp.getValue().toString().substring(2) );	// 截取
			System.out.println(cp.getValue() );
		});
	}
}





